package com.SuanFa.ZuoChengYun;

import java.util.*;

public class a5 {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        //在此输入您的代码...
        int a = scan.nextInt();
        int[][] nums = new int[3][4];
        for (int i = 0; i < a; i++) {
            nums[i][0] = scan.nextInt();
            nums[i][1] = scan.nextInt();
            nums[i][2] = scan.nextInt();
            nums[i][3] = scan.nextInt();
        }
        int[][] num = {{0, 1, 2},
                {0, 2, 1},
                {1, 0, 2},
                {1, 2, 0},
                {2, 0, 1},
                {2, 1, 0}};
        double[] temp = new double[6];
        for (int i = 0; i < num.length; i++) {
            double m=0;
            int i1 = nums[num[i][0]][0];
            int i2 = nums[num[i][0]][1];
            int i3 = nums[num[i][0]][2];
            int i4 = nums[num[i][0]][3];

            int i5 = nums[num[i][1]][0];
            int i6 = nums[num[i][1]][1];
            int i7 = nums[num[i][1]][2];
            int i8 = nums[num[i][1]][3];

            int i9 = nums[num[i][2]][0];
            int i10= nums[num[i][2]][1];
            int i11= nums[num[i][2]][2];
            int i12= nums[num[i][2]][3];
            double pow1 = Math.pow((i1 - i5), 2);
            double pow2 = Math.pow((i2 - i6), 2);
            double pow3 = Math.pow((i3 - i7), 2);
            m+=Math.sqrt(pow1+pow2+pow3)*i8;

            double pow4 = Math.pow((i5 - i9), 2);
            double pow5 = Math.pow((i6 - i10), 2);
            double pow6 = Math.pow((i7 - i11), 2);
            m+=Math.sqrt(pow4+pow5+pow6)*i12;
            temp[i]=m;
        }
        double temps=temp[0];
        for (int i = 1; i < temp.length; i++) {
            if (temps>temp[i]){
                temps=temp[i];
            }
        }
        System.out.printf("%.2f%n",temps);
        scan.close();
    }
}
